<form action="index.php" method="post" name="adminForm" id="adminForm">

<?
  $division      = null;
  $division_id   = null;
  $division_name = null;
  $division_color= null;
  $division_infos= null;
  $published     = false;
  
  if(isset($this->division)){
    $division       = $this->division;
	$division_id    = $division->id;
    $division_name  = $division->name;
    $division_color = $division->color;
    $division_infos = $division->infos;
    $published      = $division->published;
  }
  
  $divisions = null;
  if(isset($this->divisions))
    $divisions = $this->divisions;
  
  $division_conferences = null;
  if(isset($this->division_conferences))
    $division_conferences = $this->division_conferences;
  
  $conferences = array();
  if(isset($this->conferences))
  $conferences = $this->conferences;
 ?>
 
<script type="text/javascript">
jQuery(document).ready(
  function(){
    jQuery("#adminForm").validate({
      rules:  {
        name: "required",
      }
    });
    
    jQuery('.simple_color').simpleColor({
      boxWidth: 50,
      boxHeight: 15,
      displayColorCode: true
    });
  }
);
</script>
  <fieldset class="adminform">
    <legend>Details</legend>
            <table class="admintable" width="100%">
                <tr>
                    <td class="key">Name</td>
          <td>
            <input type="text" name="name" id="name" size="40" value="<?= $division_name; ?>" />
          </td>
        </tr>
        <tr>
          <td class="key">Color</td>
          <td>
            <input class='simple_color' id="color" name="color" <? if($division_color):?>
                                                                  <?= "value=$division_color" ?>
                                                                            <? endif; ?>/>
          </td>
        </tr>
        <tr>
                    <td class="key">Infos</td>
          <td>
            <?= $this->editor->display( 'infos', $division_infos, '100%', '480', '80', '15' ) ?>
          </td>
        </tr>
                <tr>
          <td class="key">Published</td>
          <td>
            <?= JHTML::_('select.booleanlist', 'published', 'class="inputbox"', $published); ?>
          </td>
        </tr>
        <tr>
                    <td class="key">Parent</td>
          <td>
            <select name="parent_division_id">
              <option value="0">None</option>
              <? foreach($divisions as $d): ?>
                <? if($d->id != $d->id): ?>
                  <option value="<?= $d->id ?>" <?= $d->id == $d->parent_division_id ? "selected" : "" ?>><?= $d->name ?></option>
                <? endif; ?>
              <? endforeach; ?>
            </select>
          </td>
        </tr>            
      </table>
       </fieldset>
     
     <fieldset>
    <legend>Relationship</legend>
    <table class="admintable">
      <tr>
        <td class="key">Division Conferences</td>
        <td>
          <?
            $conference_ids = array();
            if(is_array($division_conferences)){
              foreach($division_conferences as $division_conference)
                array_push($conference_ids, $division_conference->conference_id);
            }
            
          ?>
          <?= JHTML::_('select.genericlist', $conferences, 'conferences[]', 'multiple=multiple size=10', 'id', 'name', $conference_ids); ?>
        </td>
      </tr>
    </table>
     </fieldset>
     
       <input type="hidden" name="option" value="<?php echo JRequest::getVar( 'option' );?>"/>
       <input type="hidden" name="c" value="<?php echo JRequest::getVar('c', 'division'); ?>" />
       <input type="hidden" name="id" value="<?php echo $division_id; ?>"/>      
       <input type="hidden" name="task" value=""/>
</form>